import map_block

class Viewport(map_block.Block):
	def __init__(self, x, y, w, h):
		super(Viewport,self).__init__( x, y, w, h)
		self.con = None
		
	def cord_view(self,x,y):
		return (x - self.x, y - self.y)

	def cord_world(self,x,y):
		return (x + self.x, y + self.y)

		
	def get_tile(self, map, x, y):
		
		(map_x,map_y) = self.cord_world(x,y)
		
		if map.tiles.has_key((map_x,map_y)):
		
		#if map_x < map.w and map_x > 0:
			#if map_y < map.h and map_y > 0:
				return map.get_tile(map_x,map_y)
				
		return None
	
